package wsepForum.network.server;

import java.net.Socket;

import wsepForum.domain.ForumDomain;
import wsepForum.network.common.GUIRequest;
import wsepForum.network.server.gate.IUIController;

/**
 * Used to create new GUI connection handler once a client connects
* @author Oren Ben-Haim
*
*/
public class GUIConnectionHandlerFactory implements
		IConnectionHandlerFactory {

	/**
	 * Main forum domain
	 */
	final private ForumDomain domain;
	/**
	 * ui controller to attach the new connections handlers
	 */
	private IUIController<GUIToken<GUIRequest>> ui;
	/*****************************
	 * CONSTRUCTOR               *
	 *****************************/
	public GUIConnectionHandlerFactory(ForumDomain domain, IUIController<GUIToken<GUIRequest>> ui) {
		this.domain = domain;
		this.ui = ui;
	}
	
	/*****************************
	 * MEMBERS                   *
	 *****************************/
	/* (non-Javadoc)
	 * @see wsepForum.network.server.IConnectionHandlerFactory#newHandler(java.net.Socket)
	 */
	public ConnectionHandler<?> newHandler(Socket socket) {
		return new GUIConnectionHandler(socket, this.domain.createNewSession(), this.ui);
	}

}
